﻿@model Otter.Models.ArticleSearchModel
@{
  ViewBag.Title = string.Format(Model.IsTagSearch ? (string.IsNullOrEmpty(Model.Query) ? "Untagged articles" : "Articles tagged \"{0}\"") : "Search results for \"{0}\"", Model.Query);
}
<h1>@ViewBag.Title</h1>
@if (Model.Tags.Any())
{
  <h2><small>Tags:</small></h2>
  <div class="tags">
  @foreach (var tag in Model.Tags)
  {
  <span class="label label-default">@Html.ActionLink(tag, "Tagged", new { id = tag })</span>
  }
  </div>
}
@if (Model.Articles.Any())
{
  <h2><small>@Model.Articles.Count() article(s) returned:</small></h2>
  <ul class="list-unstyled">
    @foreach (var article in Model.Articles)
    {
      <li>
        <div>@Html.ActionLink(article.Title, "Read", new { id = article.UrlTitle }, new { @class = "" })</div>
        <div class="search-result-details">@string.Format("Last updated {0:g}{1}", article.UpdatedDtm, string.IsNullOrEmpty(article.UpdatedBy) ? string.Empty : " by " + article.UpdatedByDisplayName ?? article.UpdatedBy)</div>
      </li>
    }
  </ul>
}
else
{
  <p class="lead">No matching articles could be found.</p>
}